package com.ctbri.io;

import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;

public class Ex23 {
	
	public static void printCharBuffer(CharBuffer charBuffer) {
		while(charBuffer.hasRemaining()){
			System.out.print(charBuffer.get());
		}
	}
	
	public static void main(String[] args) throws UnsupportedEncodingException {
		ByteBuffer byteBuffer = ByteBuffer.wrap("Hello world, this is just a test.".getBytes());
		printCharBuffer(Charset.forName("GBK").decode(byteBuffer));
	}
}
